<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <ul>
        <!-- 只要使用v-for，就需要无脑的加上key属性 -->
        <!-- key属性只能加基础类型 string或者数字 -->

        <!-- 尽可能不要使用index作为key，很多使用没法复用 -->
        <li v-for="(item, index) in list" :key="index">{{ item.name }}</li>
      </ul>
      <button @click="fn">btn</button>
    </div>

    <script src="../Vue.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {
          list: [
            {
              id: 1,
              name: "zhangsan",
            },
            {
              id: 2,
              name: "lisi",
            },
            {
              id: 3,
              name: "wangwu",
            },
          ],
        },
        methods: {
          fn() {
            this.list.push({
              id: 4,
              name: "zhaoliu",
            });
          },
        },
      });
    </script>
  </body>
</html>
